package com.ll.homework;

/**
 * 工厂类,获取交通工具
 */
public class VehicleFactory {
    // 马儿始终是同一匹
    // 单例模式,饿汉式
    private static Horse horse= new Horse();

    private VehicleFactory(){};

    public static Horse getHorse() {
        if (horse == null) {
            horse = new Horse();
        }
        return new Horse();
    }

    public static Boat getBoat(){
        return new Boat();
    }

    public static Airplane getAirplane() {
        return new Airplane();
    }
}
